package com.ruoyi.web.controller.system;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.TankInfo;
import com.ruoyi.system.domain.vo.DeviceVo;
import com.ruoyi.system.domain.vo.TankStatusCardData;
import com.ruoyi.system.domain.vo.TankStatusCountData;
import com.ruoyi.system.service.TankInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 缸 前端控制器
 * </p>
 *
 * @author tianfu-li
 * @since 2025-44-27
 */
@RestController
@RequestMapping("/tankInfo")
@Api(tags = "缸模块")
public class TankInfoController {
    @Autowired
   private TankInfoService tankInfoService;
    @GetMapping ("/getTankInfoByLineNo")
    @ApiOperation(value = "查询设备当前状态")
    public R<List<TankInfo>> getTankInfo(@RequestParam(value = "lineNo", required = false, defaultValue = "" )Long lineNo){
        List<TankInfo> tankInfos=null;
        if(lineNo!=null){
            tankInfos=tankInfoService.getTankInfoByLineNo(lineNo);
        }else{
            tankInfos=tankInfoService.getTankInfo();
        }

        if(tankInfos.size()>0){
            return R.ok(tankInfos);
        }else{
            return R.fail("查询失败");
        }
    }
    @GetMapping ("/getNowTankInfo")
    @ApiOperation(value = "查询大屏展示设备数据")
    public R<List<DeviceVo>> getNowTankInfo(){
        List<DeviceVo> deviceVos=tankInfoService.getNowTankInfo();

        if(deviceVos.size()>0){
            return R.ok(deviceVos);
        }else{
            return R.fail("查询失败");
        }
    }
    @GetMapping ("/getTankStatusCountData")
    @ApiOperation(value = "获取设备状态数量")
    public R<TankStatusCountData> getTankStatusCountData(){
        TankStatusCountData tankStatusCountData=tankInfoService.getTankStatusCountData();

        if(tankStatusCountData!=null){
            return R.ok(tankStatusCountData);
        }else{
            return R.fail("查询失败");
        }
    }
    @GetMapping ("/getTankStatusCardData")
    @ApiOperation(value = "获取设备状态数量")
    public R<List<TankStatusCardData>> getTankStatusCardData(){
        List<TankStatusCardData> tankStatusCardDataList=tankInfoService.getTankStatusCardData();

        if(tankStatusCardDataList.size()>0){
            return R.ok(tankStatusCardDataList);
        }else{
            return R.fail("查询失败");
        }
    }
    @GetMapping ("/getMyChartData")
    @ApiOperation(value = "获取设备状态数量")
    public R<Map<String, Object>> getMyChartData(){
       Map<String, Object> map=tankInfoService.getMyChartData();

        if(map!=null){
            return R.ok(map);
        }else{
            return R.fail("查询失败");
        }
    }
}
